define('controllers/sp_advice', function (require, exports, module) {
	"use strict";

	var fnGlobalUrl = require[require.toUrl ? 'toUrl' : 'resolve'];
	var $window = $(window),
		$document = $(document);
	require('jplayer');
	require('jplayer.playlist');

  	require('nicescroll');
	/*var m_Swiper = require('swiper');*/ //引用一个js插件实例

	/* ************************************************************ */
	var m_AdvicePage = { /* 定义一个首页对象 */
		createNew: function () {
			if(!(window.basePage) || typeof(window.basePage.createNew) !=='function'){
				window.basePage={};
				window.basePage.createNew=function(){
					return {};
				}
			}
			var $internal = window.basePage.createNew();
			/* code here for example */
			$internal.adviceVideo = null;

			$internal.init = function () { /* 页面类的初始化， 向$internal上绑定功能对象， 如下绑定 Banner 对象 */
				/*code here 如下： */
				this.adviceVideo = new $adviceVideo();
			};
			var $adviceVideo = new Class({ /* 创建banner对象 */
				initialize: function () {
					this._init();
				}
			});
			$adviceVideo.extend({ /* 向banner对象添加 banner的方法  */
				_init: function () {
					this.isAppear = false; /* 是否呈现完毕标志 */
					this.mySwiper = null;
					this.myTimers = undefined; /* 预定义定时器  */
					this.videoData = [];
					this.introduce = $('.J_introduce');
				},
				appear: function () { /* 呈现相关逻辑  如swiper 的配置和和绑定等 */
					var _this = this;
							_this.videoData = _this.getVideoList();
					_this.foundVideoList(_this.videoData);
					if(_this.videoData.length>0){
						_this.introduce.html(_this.videoData[0].videoIntroduce);
					}else {
						$('.hd-video-items').append('<li class="noHas hd-video-item">暂无视频</li>')
					}

					$('body').on('click','.jp-playlist-item',function(){
						var _the = $(this),
								num = _the.parents('li').index();
						_this.introduce.html(_this.videoData[num].videoIntroduce);
					});
					//滚动条美化
					if($(".J_scroll_bar").length>0){
						$(".J_scroll_bar").niceScroll({
							cursorcolor: '#e0e0e0',
							cursorwidth: '8px',
							cursorborder: '1px solid #f1f1f1',
							autohidemode: 'leave',
							background: 'none'
			      });
					}
				},
				foundVideoList: function(videoList){
					new jPlayerPlaylist({
						jPlayer: "#jquery_jplayer_1",
						cssSelectorAncestor: "#jp_container_1"
					},videoList,{
						swfPath: "../../dist/jplayer",
						supplied: "webmv, ogv, m4v, oga, mp4, mp3",
						useStateClassSkin: true,
						autoBlur: false,
						smoothPlayBar: true,
						keyEnabled: true,
						audioFullScreen: true,
						size: {
							width: "569px",
							height: "320px",
							cssClass: "jp-video-360p hasVideo"
						},
					});
				},
				getVideoList: function(){
					var _this = this,
							newData = [];
					$('.J_video_list').find('li').each(function(){
						var _the = $(this),
								num = _the.index();
						newData[num] = {};
						newData[num].title = _the.find('.video_title').text();
						newData[num].artist = _the.find('.page_view').text();
						if(_the.find('.mp4').length){newData[num].mp4 = _the.find('.mp4').text();}
						if(_the.find('.mp3').length){newData[num].mp3 = _the.find('.mp3').text();}
						if(_the.find('.m4v').length){newData[num].m4v = _the.find('.m4v').text();}
						if(_the.find('.ogv').length){newData[num].ogv = _the.find('.ogv').text();}
						if(_the.find('.oga').length){newData[num].oga = _the.find('.oga').text();}
						if(_the.find('.webmv').length){newData[num].webmv = _the.find('.webmv').text();}
						newData[num].poster = _the.find('.poster').text();
						newData[num].videoIntroduce = _the.find('.video_info').html();	
					});

					console.log(newData);
					return newData;
				}
			});
			return $internal; //返回对象
		}
	};
	exports.run = function (){
		var ADVICEPAGE = m_AdvicePage.createNew(); /* 定义首页页面类 */
		ADVICEPAGE.init(); /* 调用首页页面类入口方法  */
		$document.ready(function () {
			ADVICEPAGE.adviceVideo.appear(); /* 当dom 加载完成后调用 banner 的呈现函数 */
		});
	};
});
